package by.siarhei.java.tij.reusing.exercises.ex23;

import by.siarhei.java.tij.reusing.exercises.ex23.com.pkg.ClassWithConstructor;
import by.siarhei.java.tij.reusing.exercises.ex23.com.pkg.ClassWithStaticField;

/**
 * @author Siarhei Shchahratsou <s.siarhei@gmail.com>
 * @since 23.03.2014
 */
public class Exercise23 {
    public static void main(String[] args) {
        System.out.println("-Accessing static member at first time (must be loaded here):");
        //NOTE: if ClassWithStaticField.A_STRING is final
        // (and is initialized by literal, not expression), then class won't be loaded
        String s = ClassWithStaticField.A_STRING;
        System.out.println("\n-Accessing static member at second time (mustn't be loaded, because already done):");
        s = ClassWithStaticField.A_STRING;

        System.out.println("\n\n-Creating object at first time (must be loaded here):");
        new ClassWithConstructor();
        System.out.println("\n-Creating object at second time (mustn't be loaded, because already done):");
        new ClassWithConstructor();
    }
}
